import axios from 'axios'
export const baseURL = 'http://119.23.78.227:1337'

// 配置基地址
const request = axios.create({
  baseURL,
  timeout: 35000
})

request.interceptors.response.use(response => {
  // 数据剥离
  return response.data
}, error => {
  return Promise.reject(error)
});

// 图标
export function getIconAPI() {
  return request({
    url: '/api/icon',
    params: {
      populate: '*'
    }
  })
}

// 植物检疫信息
export function getPlantQuarantineAPI() {
  return request({
    url: '/api/plant-quarantines',
    params: {
      populate: '*'
    }
  })
}

// 首页轮播图图片
export function getHomecarouselAPI() {
  return request({
    url: '/api/home-carousels',
    params: {
      populate: '*'
    }
  })
}

// 首页小图片信息图片
export function getHomeStatisticAPI() {
  return request({
    url: '/api/home-statistics',
    params: {
      populate: '*'
    }
  })
}

// 首页分类图片数组图片
export function getHomeCategoryBlockAPI() {
  return request({
    url: '/api/home-category-blocks',
    params: {
      populate: '*'
    }
  })
}

// 项目介绍信息
export function getProjectIntroductionAPI() {
  return request({
    url: '/api/project-introductions',
    params: {
      populate: '*'
    }
  })
}

// 项目功能介绍信息
export function getProjectFunctionAPI() {
  return request({
    url: '/api/project-functions',
    params: {
      populate: '*'
    }
  })
}

// 项目动态信息
export function getProjectDynamicAPI() {
  return request({
    url: '/api/project-dynamics',
    params: {
      populate: '*'
    }
  })
}

// 入侵物种名录界面的信息
export function getInvasiveSpeciesDirectoryAPI() {
  return request({
    url: '/api/list-of-invasive-species',
    params: {
      populate: '*'
    }
  })
}

// 培训课程信息
export function getTrainingCourseAPI(req) {
  return request({
    url: '/api/training-courses',
    params: {
        'pagination[page]': req.pageNo,
        'pagination[pageSize]': req.pageSize,
        populate: '*'
    }
  })
}

// 成果展示信息
export function getResultDisplayAPI(req) {
  return request({
    url: '/api/results-displays',
    params: {
        'pagination[page]': req.pageNo,
        'pagination[pageSize]': req.pageSize,
        populate: '*'
    }
  })
}

// 微影视图片信息
export function getMicrovideoPictureAPI(req) {
  return request({
      url: '/api/microvideo-pictures',
      params: {
          'pagination[page]': req.pageNo,
          'pagination[pageSize]': req.pageSize,
          populate: '*'
      }
  });
}



